package com.restaurant.application.reservation.support;

import com.nebutown.base.ViewSpec;
import com.nebutown.base.data.ViewUpdate;
import com.nebutown.description.data.UnitForGeneration;
import com.nebutown.generation.PickableBean;
import com.nebutown.supporthome.AbstractBase;
import com.nebutown.supporthome.CmdCapsule;
import com.restaurant.application.indexes.reservationlist.mysql.ReservationListBean;
import com.restaurant.application.reservation.ReservationImpl;

public class ReservationBase extends AbstractBase {
    private UnitForGeneration desc = new UnitForGeneration();

    public AbstractReservation getImpl() {
        AbstractReservation inst = new ReservationImpl();
        inst.setBase(this, getEscort());
        return inst;
    }

    @Override
    public ReservationOutFace getUnitFace() {
        return new ReservationOutFace(this);
    }

    @Override
    protected Object callDistr(String name, Object... param) {
        switch(name) {
            case "update": return getImpl().update((ReservationData)param[0]);
            case "init": return getImpl().init((ReservationData)param[0]);
            case "cancel":
                return getImpl().cancel();
            case "getReservationBean": return getImpl().getReservationBean();
            case "getId": return getImpl().getId();
            case "getEffectiveInterface": return getImpl().getEffectiveInterface();
            case "getViewLead":
                return getImpl().getViewLead((ViewSpec) param[0]);
            case "getFullView":
                setIsRefresher();
                return getImpl().getFullView();
            case "getReservationUidDataForReservationList": return getImpl().getReservationUidDataForReservationList((ReservationListBean)param[0]);
        }
        return null;
    }

    @Override
    protected boolean authDistr(String name) {
        switch(name) {
        }
        return true;
    }

    @Override
    public CmdCapsule getUICall(int cmd) {
        switch(cmd) {
            case 0: return AbstractReservation.CMD_MODIFY;
            case 1:
                return AbstractReservation.CMD_REFUSE;
            case 2:
                return AbstractReservation.CMD_CANCEL;
        }
        return null;
    }

    @Override
    public ViewUpdate uiCall(int cmd, PickableBean param, int... seq) {
        switch(cmd) {
            case 0: return getImpl().modify((ReservationData)param, seq);
            case 1:
                return getImpl().refuse(seq);
            case 2:
                return getImpl().cancel(seq);
        }
        return null;
    }
}
